#ifndef ADDIMAGEALGORITHMWIDGETBUTTON_H
#define ADDIMAGEALGORITHMWIDGETBUTTON_H

#include <QLabel>
#include <QPushButton>
#include <QStyle>
#include "ui_ImageAlgorithmButton.h"

class ImageAlgorithmButton : public QPushButton
{
    Q_OBJECT
    Q_PROPERTY(bool checked READ isChecked WRITE setChecked NOTIFY toggled)
    Q_PROPERTY(bool processed READ isProcessed WRITE setProcessed NOTIFY processedChanged)
    Q_PROPERTY(bool hasSettingsWidget READ hasSettingsWidget WRITE setHasSettingsWidget NOTIFY hasSettingsWidgetChanged)

public:
    ImageAlgorithmButton(QWidget *parent = nullptr);

    // 设置按钮文字
    void setText(const QString &text);
    // 设置左侧图标（资源路径形式）
    void setIcon(const QString &iconPath);
    
    // 获取和设置处理状态
    bool isProcessed() const { return m_isProcessed; }
    void setProcessed(bool processed);
    
    // 获取和设置是否有设置widget
    bool hasSettingsWidget() const { return m_hasSettingsWidget; }
    void setHasSettingsWidget(bool hasWidget);
    
    ~ImageAlgorithmButton();

 signals:
    // 状态切换信号（作为主要的交互信号）
    void toggled(bool checked);
    // 是否有设置widget变化信号
    void hasSettingsWidgetChanged(bool hasWidget);
    // 处理状态变化信号
    void processedChanged(bool processed);

 protected:
    // 重写事件，实现鼠标悬停和离开效果
    void enterEvent(QEvent *event) override;
    void leaveEvent(QEvent *event) override;
private:
    //更新箭头
    void updateArrow(bool checked);
 private slots:
    // 处理按钮状态改变
    void onToggled(bool checked);

 private:
    Ui::ImageAlgorithmButton *ui;  // UI表单指针
    bool m_hasSettingsWidget; // 是否有设置widget
    
    // 图形已处理状态
    bool m_isProcessed;

};
#endif // ADDIMAGEALGORITHMWIDGETBUTTON_H
